package progressBar;

import android.app.Dialog;
import android.content.Context;
import android.support.v4.view.ViewPager.LayoutParams;
import android.util.Log;
import android.view.Gravity;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import bls.juejin.cn.R;


public class MyProgress extends Dialog{
public static MyProgress customMyProgressBar = null;
	
	public static Animation am;
	
	public static ImageView imageView;
	
	public static TextView tvProgress;

	public MyProgress(Context context, int theme) {
		super(context, theme);
	}

	protected MyProgress(Context context, boolean cancelable,
			OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
	}


	public MyProgress(Context context) {
		super(context);
	}
	
	public static MyProgress createDialog(Context context,String msg){
		Log.d("TAG", "MSG---------------------》"+msg);
		customMyProgressBar = new MyProgress(context,R.style.MyProgressDialog);
		customMyProgressBar.setContentView(R.layout.loading_dialog);
//		customMyProgressBar.getWindow().getAttributes().gravity = Gravity.CENTER;
//		customMyProgressBar.getWindow().getAttributes().height = LayoutParams.WRAP_CONTENT;
//		customMyProgressBar.getWindow().getAttributes().width = LayoutParams.WRAP_CONTENT;

		imageView = (ImageView) customMyProgressBar
				.findViewById(R.id.ivProgressCenter);
		LinearInterpolator lin=new LinearInterpolator();

		tvProgress = (TextView) customMyProgressBar.findViewById(R.id.tvProgress);
		if (null == am) {
			am = AnimationUtils.loadAnimation(context, R.anim.dialog_loading_anim);
			am.setInterpolator(lin);
		} else {
			imageView.clearAnimation();
			
			am = AnimationUtils.loadAnimation(context, R.anim.dialog_loading_anim);
			am.setInterpolator(lin);
		}
		imageView.setAnimation(am);
		tvProgress.setText(msg);
		return customMyProgressBar;
	}

	
}
